//
//  XMRealNameAuthenViewController.m
//  XMJJ_zml
//
//  Created by apple on 2025/5/20.
//

#import "XMRealNameAuthenViewController.h"
#import "XMRealNameAuthenView.h"
#import "XMNetwork+mine.h"
#import "XMServiceInfoViewController.h"

@interface XMRealNameAuthenViewController ()

@property (nonatomic, strong) XMRealNameAuthenView *realNameAuthenView;

@end

@implementation XMRealNameAuthenViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self creatUI];
}

- (void)creatUI {
    [self.view addSubview:self.realNameAuthenView];
    [_realNameAuthenView setContentWithUserModel:_userInfoModel];
}

- (void)realNameAuthenActionWithName:(NSString *)nameStr
                                idNo:(NSString *)idNo {
    XMWeakSelf;
    [_Network realNameAuthenWithName:nameStr
                                idNo:idNo
                             success:^(id  _Nonnull responseObject) {
        [MBProgressHUD showSuccess:@"认证成功"];
        [weakSelf.navigationController popViewControllerAnimated:YES];
    } failure:^(NSError * _Nonnull error) {
        
    }];
}

- (XMRealNameAuthenView *)realNameAuthenView {
    if (!_realNameAuthenView) {
        _realNameAuthenView = [[XMRealNameAuthenView alloc] initWithFrame:self.view.bounds];
        XMWeakSelf;
        _realNameAuthenView.realNameAuthenBlock = ^(NSString * _Nonnull name, NSString * _Nonnull idNo) {
            [weakSelf realNameAuthenActionWithName:name idNo:idNo];
        };
        _realNameAuthenView.checkServiceInfoBlock = ^{
            XMServiceInfoViewController *serviceInfoVC = [[XMServiceInfoViewController alloc] init];
            serviceInfoVC.type = @"5";
            serviceInfoVC.title = @"实名认证服务协议";
            [weakSelf.navigationController pushViewController:serviceInfoVC animated:YES];
        };
    }
    return _realNameAuthenView;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
